params range
Type
function
Summary
Returns a range of parameters passed to the current handler as an array.
Syntax
params(<firstParameter> [, <lastParameter>])
Description
Use the params function within a handler to get an array of parameters that were passed to the handler.
The range of parameters to return is defined by firstParameter and, optionally, lastParameter with firstParameter defining the first parameter to return, and lastParameter defining the last parameter to return. If lastParameter is not present then it is taken to be the number of parameters passed to the handler.
Positive values indicate a one-based index into the parameters passed to the handler.
Negative values indicate a index relative to the end of the parameters passed to the handler.
The resulting range is clamped to be between 1 and the paramCount. If the last index resolves to less than the first index, an empty range is returned.
For example, the following function returns the the second to penultimate parameter passed to it, as an array:
function middleParams
return params(2, -2)
end middleParams
This results in the following behavior:
put middleParams(1, 2, 3, 4)
=> [ 2, 3 ]
put middleParams(1, 2, 3)
=> [ 2 ]
put middleParams(1, 2)
=> [ ]
Note:The params function operates on the actual parameters passed
to the handler, not a handler\'s named parameters. For
example, if only one parameter is passed to a handler with three named
parameters, the params function will only ever return at most one
element in the array.
Parameters
Name | Type | Description |
---|---|---|
firstParameter | A positive or negative integer, indicating which parameter to fetch first. | |
lastParameter | A positive or negative integer, indicating which parameter to fetch last. |
Examples
params(1)
put params(-2, -1) into lastTwoParameters
Related
command: call
control structure: function
function: paramCount
glossary: pass, handler, parameter, function handler, return, value
Compatibility and Support
Introduced
LiveCode 10.0
OS
mac
windows
linux
ios
android
web
Platforms
desktop
server
mobile